package com.belizer.demo.thread;

import java.util.ArrayList;
import java.util.List;

public class Demo4 {

    public static void main(String[] args) {
//        ThisEscape.EventSource eventSource = new ThisEscape.EventSource() {
//            @Override
//            public void registerListener(ThisEscape.EventListener e) {
//
//            }
//        };

//        ThisEscape thisEscape = new ThisEscape(eventSource);
    }

    public static class ThisEscape {
        private final List<Event> listOfEvents;

        public ThisEscape(EventSource source) {
            source.registerListener(new EventListener() {
                public void onEvent(Event e) {
                    doSomething(e);
                }
            });
            listOfEvents = new ArrayList<Event>();
        }

        void doSomething(Event e) {
            listOfEvents.add(e);
        }


        interface EventSource {
            void registerListener(EventListener e);
        }

        interface EventListener {
            void onEvent(Event e);
        }

        interface Event {
        }
    }
}
